package com.gbiac.toc.event.controller;

import com.gbiac.toc.comment.entity.EventCommentEntity;
import com.gbiac.toc.common.AjaxApiJson;
import com.gbiac.toc.dynamics.entity.EventDynamicsEntity;
import com.gbiac.toc.event.entity.EventEntity;
import com.gbiac.toc.event.entity.EventStatusEntity;
import com.gbiac.toc.event.entity.MyDepart;
import com.gbiac.toc.event.entity.Person;
import com.gbiac.toc.event.page.EventPage;
import com.gbiac.toc.event.service.EventExcleService;
import com.gbiac.toc.event.service.EventServiceI;
import com.gbiac.toc.eventtype.entity.EventTypeEntity;
import com.gbiac.toc.messagePush.Jpush;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URI;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.jeecgframework.core.beanvalidator.BeanValidators;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.constant.Globals;
import org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil;
import org.jeecgframework.core.util.ContextHolderUtils;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.ExceptionUtil;
import org.jeecgframework.core.util.MyBeanUtils;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.tag.vo.datatable.SortDirection;
import org.jeecgframework.web.cgform.entity.upload.CgUploadEntity;
import org.jeecgframework.web.cgform.service.config.CgFormFieldServiceI;
import org.jeecgframework.web.system.pojo.base.TSDepart;
import org.jeecgframework.web.system.pojo.base.TSUser;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

@Scope("prototype")
@Controller
@RequestMapping({"/eventController"})
public class EventController
        extends BaseController
{
  private static final Logger logger = Logger.getLogger(EventController.class);
  @Autowired
  private EventExcleService excleService;
  @Autowired
  private EventServiceI eventService;
  @Autowired
  private SystemService systemService;
  @Autowired
  private Validator validator;
  @Autowired
  private CgFormFieldServiceI cgFormFieldService;

  @RequestMapping(params={"list"})
  public ModelAndView list(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventList");
  }

  @RequestMapping(params={"bulu"})
  public ModelAndView bulu(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListBu");
  }

  @RequestMapping(params={"doing"})
  public ModelAndView doing(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListDoing");
  }

  @RequestMapping(params={"datagrid"})
  public void datagrid(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();
    String createName = event.getCreateName();
    Integer status = Integer.valueOf(event.getStatus() == null ? -1 : event.getStatus().intValue());
    if (status.intValue() == 9) {
      event.setStatus(null);
    }
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end)) {
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_end));
      }
      cq.eq("isdelete", Integer.valueOf(0));
      if (status.intValue() == 9)
      {
        cq.notEq("status", Integer.valueOf(7));
        cq.notEq("status", Integer.valueOf(9));
      }
      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();
    this.eventService.getDataGridReturn(cq, true);
    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"datagridDoing"})
  public void datagridDoing(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end))
      {
        Date end = new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end);
        Calendar cal = Calendar.getInstance();
        cal.setTime(end);
        cal.add(5, 1);
        String endtime = DateUtils.formatDate(cal);
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(endtime));
      }
      Object[] objects = { Integer.valueOf(4), Integer.valueOf(8) };
      cq.in("status", objects);
      cq.eq("isdelete", Integer.valueOf(0));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();
    this.eventService.getDataGridReturn(cq, true);
    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"doDel"})
  @ResponseBody
  public AjaxJson doDel(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    event = (EventEntity)this.systemService.getEntity(EventEntity.class, event.getId());
    String message = "事件删除成功";
    try
    {
      this.eventService.delMain(event);
      this.systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "事件删除失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doBatchDel"})
  @ResponseBody
  public AjaxJson doBatchDel(String ids, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "事件删除成功";
    j.setSuccess(true);
    try
    {
      for (String id : ids.split(","))
      {
        EventEntity event = (EventEntity)this.systemService.getEntity(EventEntity.class, id);

        this.eventService.delMain(event);
        this.systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
      j.setSuccess(false);
      message = "事件删除失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doAdd"})
  @ResponseBody
  public AjaxJson doAdd(EventEntity event, EventPage eventPage, HttpServletRequest request, HttpServletResponse response)
          throws IOException
  {
    if (StringUtils.isNotBlank(eventPage.getDepart()))
    {
      Cookie recipientCookie = new Cookie(eventPage.getDepart(), eventPage.getRecipient());
      recipientCookie.setMaxAge(2592000);
      recipientCookie.setPath("/");
      response.addCookie(recipientCookie);
    }
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();

    TSUser user = ResourceUtil.getSessionUser();
    String content = event.getContent();
    if (content.length() > 10) {
      content = content.substring(0, 10);
    }
    for (int index = 0; index < eventDynamicsList.size(); index++) {
      if (((EventDynamicsEntity)eventDynamicsList.get(index)).getDycontent().isEmpty()) {
        eventDynamicsList.remove(index);
      }
    }
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();
    for (int index = 0; index < eventCommentList.size(); index++) {
      if (((EventCommentEntity)eventCommentList.get(index)).getComment().isEmpty())
      {
        eventCommentList.remove(index);
      }
      else
      {
        String comment = ((EventCommentEntity)eventCommentList.get(index)).getComment();
        comment = user.getRealName() + " " + comment;
        ((EventCommentEntity)eventCommentList.get(index)).setComment(comment);
      }
    }
    AjaxJson j = new AjaxJson();
    String message = "添加成功";
    try
    {
      event.setIsrecive(Integer.valueOf(0));
      event.setIsdelete(Integer.valueOf(0));
      event.setTimeoutStatus(Integer.valueOf(1));
      event.setUserid(user.getId());
      String name = user.getRealName();
      EventDynamicsEntity entity = new EventDynamicsEntity();
      entity.setCreateDate(new Date());
      if (StringUtils.isNotBlank(event.getDepart()))
      {
        if ("0".equals(event.getDepart()))
        {
          String date = DateUtils.formatDate(new Date(), "MM-dd HH:mm");
          entity.setDycontent(date + "等待指派责任部门.");
          eventDynamicsList.add(entity);
          this.eventService.addMain(event, eventDynamicsList, eventCommentList);
          sendDepart("4", event.getId(), content);

          ArrayList<String> ids = this.eventService.getAllUser();
          for (String userid : ids)
          {
            boolean flag = this.eventService.isExists(userid);
            if (flag)
            {
              int auit = this.eventService.getIndex(userid, "nodepart_total");
              this.eventService.updateIndex(userid, "nodepart_total", auit);
            }
            else
            {
              this.eventService.addIndex(userid, "nodepart_total");
            }
          }
        }
        else
        {
          String eventDepartName = this.excleService.getEventDepart(event.getDepart());
          String date = DateUtils.formatDate(new Date(), "MM-dd HH:mm");
          if (event.getStatus().intValue() == 3)
          {
            entity.setDycontent(date + " " + name + "指派事件给" + eventDepartName);
            eventDynamicsList.add(entity);
            this.eventService.addMain(event, eventDynamicsList, eventCommentList);

            sendInfo("1", event.getId(), content, event.getDepart());
          }
          else if (event.getStatus().intValue() < 3)
          {
            entity.setDycontent(date + " " + name + "上报事件");
            eventDynamicsList.add(entity);
            this.eventService.addMain(event, eventDynamicsList, eventCommentList);
          }
          ArrayList<String> ids = this.eventService.getRole(event.getDepart());
          for (String userid : ids)
          {
            boolean flag = this.eventService.isExists(userid);
            if (flag)
            {
              int auit = this.eventService.getIndex(userid, "auit_total");
              this.eventService.updateIndex(userid, "auit_total", auit);
            }
            else
            {
              this.eventService.addIndex(userid, "auit_total");
            }
          }
        }
      }
      else
      {
        String date = DateUtils.formatDate(new Date(), "MM-dd HH:mm");
        entity.setDycontent(date + " " + name + "上报事件");
        eventDynamicsList.add(entity);
        this.eventService.addMain(event, eventDynamicsList, eventCommentList);
      }
      this.systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "事件添加失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    j.setObj(event);
    return j;
  }

  @RequestMapping(params={"doAddBu"})
  @ResponseBody
  public AjaxJson doAddBu(EventEntity event, EventPage eventPage, HttpServletRequest request)
  {
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();
    TSUser user = ResourceUtil.getSessionUser();
    for (int index = 0; index < eventDynamicsList.size(); index++) {
      if (((EventDynamicsEntity)eventDynamicsList.get(index)).getDycontent().isEmpty()) {
        eventDynamicsList.remove(index);
      }
    }
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();
    for (int index = 0; index < eventCommentList.size(); index++) {
      if (((EventCommentEntity)eventCommentList.get(index)).getComment().isEmpty())
      {
        eventCommentList.remove(index);
      }
      else
      {
        String comment = ((EventCommentEntity)eventCommentList.get(index)).getComment();
        comment = user.getRealName() + " " + comment;
        ((EventCommentEntity)eventCommentList.get(index)).setComment(comment);
      }
    }
    AjaxJson j = new AjaxJson();
    String message = "添加成功";
    try
    {
      event.setCheckStatus(Integer.valueOf(3));
      event.setIsrecive(Integer.valueOf(0));
      if (!StringUtils.isNotBlank(event.getStatus() + "")) {
        event.setStatus(Integer.valueOf(7));
      }
      event.setIsdelete(Integer.valueOf(0));
      event.setTimeoutStatus(Integer.valueOf(1));
      event.setUserid(user.getId());
      this.eventService.addMain(event, eventDynamicsList, eventCommentList);
      this.systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "事件添加失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    j.setObj(event);
    return j;
  }

  @RequestMapping(params={"doChangeDept"})
  @ResponseBody
  public AjaxJson doChangeDept(EventEntity event, EventPage eventPage, HttpServletRequest request)
  {
    HttpSession session = ContextHolderUtils.getSession();
    TSUser u = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
    String realName = u.getRealName();
    List<EventDynamicsEntity> eventDynamicsList = new ArrayList();
    List<EventCommentEntity> eventCommentList = new ArrayList();
    String content = event.getContent();
    if (content.length() > 10) {
      content = content.substring(0, 10);
    }
    AjaxJson j = new AjaxJson();
    String message = "更新成功";
    EventEntity before = (EventEntity)request.getSession().getAttribute("event");
    event.setCreateDate(before.getCreateDate());
    try
    {
      String eventDepart = this.excleService.getEventDepart(event.getDepart());
      updateDynamics("指派事件给" + eventDepart + "的", eventDynamicsList);
      this.eventService.doChangeDept(event, eventDynamicsList, eventCommentList);

      sendRecipient(event.getRecipient(), event.getId(), realName + "给您指派了事件", content);

      boolean flag = this.eventService.isExists(event.getRecipient());
      if (flag)
      {
        int auit = this.eventService.getIndex(event.getRecipient(), "my_total");
        this.eventService.updateIndex(event.getRecipient(), "my_total", auit);
      }
      else
      {
        this.eventService.addIndex(event.getRecipient(), "my_total");
      }
      request.getSession().removeAttribute("event");
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "更新事件失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doUpdate"})
  @ResponseBody
  public AjaxJson doUpdate(EventEntity event, EventPage eventPage, HttpServletRequest request)
  {
    HttpSession session = ContextHolderUtils.getSession();
    TSUser u = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
    String realName = u.getRealName();
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();
    String content = event.getContent();
    if (content.length() > 10) {
      content = content.substring(0, 10);
    }
    AjaxJson j = new AjaxJson();
    String message = "更新成功";
    EventEntity before = (EventEntity)request.getSession().getAttribute("event");
    event.setCreateDate(before.getCreateDate());
    try
    {
      if ((before.getStatus() != event.getStatus()) && (event.getStatus().intValue() < 4)) {
        event.setRecipient("");
      }
      if ((StringUtils.isNotBlank(before.getRecipient())) &&
              (!before.getRecipient().equals(event.getRecipient())) &&
              (StringUtils.isNotBlank(before.getRecipient())) && (StringUtils.isNotBlank(event.getRecipient())))
      {
        event.setIsrecive(Integer.valueOf(8));
        event.setStatus(Integer.valueOf(8));
        String name2 = this.eventService.getName(event.getRecipient());
        String eventDepart = this.excleService.getEventDepart(event.getDepart());
        updateDynamics("指派事件给" + eventDepart + "的" + name2, eventDynamicsList);
        this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

        sendRecipient(event.getRecipient(), event.getId(), realName + "给您指派了事件", content);

        boolean flag = this.eventService.isExists(event.getRecipient());
        if (flag)
        {
          int auit = this.eventService.getIndex(event.getRecipient(), "my_total");
          this.eventService.updateIndex(event.getRecipient(), "my_total", auit);
        }
        else
        {
          this.eventService.addIndex(event.getRecipient(), "my_total");
        }
      }
      if (before.getStatus().intValue() == 2)
      {
        if ((!event.getDepart().isEmpty()) && (StringUtils.isBlank(event.getRecipient())))
        {
          event.setIsrecive(Integer.valueOf(3));
          event.setStatus(Integer.valueOf(3));

          event.setRecipient("");

          String eventDepart = this.excleService.getEventDepart(event.getDepart());
          updateDynamics("指派事件给" + eventDepart + "的", eventDynamicsList);
          this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

          sendRecipient(event.getRecipient(), event.getId(), realName + "给您指派了事件", content);

          boolean flag = this.eventService.isExists(event.getRecipient());
          if (flag)
          {
            int auit = this.eventService.getIndex(event.getRecipient(), "my_total");
            this.eventService.updateIndex(event.getRecipient(), "my_total", auit);
          }
          else
          {
            this.eventService.addIndex(event.getRecipient(), "my_total");
          }
        }
        else if (!event.getDepart().isEmpty())
        {
          if (("0".equals(event.getDepart())) && (!"0".equals(before.getDepart())))
          {
            event.setStatus(Integer.valueOf(2));
            updateDynamics("等待指派责任部门.", eventDynamicsList);
            this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
            sendDepart("4", event.getId(), content);

            ArrayList<String> ids = this.eventService.getAllUser();
            for (String userid : ids)
            {
              boolean flag = this.eventService.isExists(userid);
              if (flag)
              {
                int auit = this.eventService.getIndex(userid, "nodepart_total");
                this.eventService.updateIndex(userid, "nodepart_total", auit);
              }
              else
              {
                this.eventService.addIndex(userid, "nodepart_total");
              }
            }
          }
          else if ((!"0".equals(event.getDepart())) && (event.getStatus().intValue() == 3))
          {
            String eventDepart = this.excleService.getEventDepart(event.getDepart());
            updateDynamics("指派事件给" + eventDepart, eventDynamicsList);
            this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

            sendInfo("1", event.getId(), content, event.getDepart());

            ArrayList<String> ids = this.eventService.getRole(event.getDepart());
            for (String userid : ids)
            {
              boolean flag = this.eventService.isExists(userid);
              if (flag)
              {
                int auit = this.eventService.getIndex(userid, "auit_total");
                this.eventService.updateIndex(userid, "auit_total", auit);
              }
              else
              {
                this.eventService.addIndex(userid, "auit_total");
              }
            }
          }
          else
          {
            if (event.getStatus().intValue() == 7)
            {
              event.setCloseTime(new Timestamp(System.currentTimeMillis()));
            }
            else if (event.getStatus() != before.getStatus())
            {
              EventStatusEntity statusEntity = (EventStatusEntity)this.systemService.getEntity(EventStatusEntity.class, event.getStatus());
              updateDynamics("修改事件状态为" + statusEntity.getStatusName(), eventDynamicsList);
            }
            this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
          }
        }
        else
        {
          this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
        }
      }
      else if ((before.getStatus().intValue() == 6) && (event.getStatus().intValue() == 7))
      {
        event.setRecipient(before.getRecipient());

        event.setCloseTime(new Timestamp(System.currentTimeMillis()));
        updateDynamics("TOC审核通过", eventDynamicsList);
        this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
        sendRecipientadd(event.getRecipient(), event.getId(), realName + "审核通过事件", content);

        boolean flag = this.eventService.isExists(event.getRecipient());
        if (flag)
        {
          int auit = this.eventService.getIndex(event.getRecipient(), "my_total");
          this.eventService.updateIndex(event.getRecipient(), "my_total", auit);
        }
        else
        {
          this.eventService.addIndex(event.getRecipient(), "my_total");
        }
      }
      else if ((before.getStatus().intValue() == 6) && (event.getStatus().intValue() == 4))
      {
        event.setRecipient("");
        event.setStatus(Integer.valueOf(3));

        updateDynamics("TOC审核不通过.", eventDynamicsList);
        this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

        ArrayList<String> ids = this.eventService.getRole(event.getDepart());
        for (String userid : ids)
        {
          sendRecipient(userid, event.getId(), realName + "驳回事件", content);
          boolean flag = this.eventService.isExists(userid);
          if (flag)
          {
            int auit = this.eventService.getIndex(userid, "auit_total");
            this.eventService.updateIndex(userid, "auit_total", auit);
          }
          else
          {
            this.eventService.addIndex(userid, "auit_total");
          }
        }
      }
      else
      {
        EventEntity oldEntity = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());
        if ((oldEntity.getDepart() == null) || (!oldEntity.getDepart().equals(event.getDepart())))
        {
          event.setStatus(Integer.valueOf(3));
          String eventDepart = this.excleService.getEventDepart(event.getDepart());
          updateDynamics("指派事件给" + eventDepart, eventDynamicsList);
          this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

          sendInfo("1", event.getId(), content, event.getDepart());

          ArrayList<String> ids = this.eventService.getRole(event.getDepart());
          for (String userid : ids)
          {
            boolean flag = this.eventService.isExists(userid);
            if (flag)
            {
              int auit = this.eventService.getIndex(userid, "auit_total");
              this.eventService.updateIndex(userid, "auit_total", auit);
            }
            else
            {
              this.eventService.addIndex(userid, "auit_total");
            }
          }
        }
        else if (event.getStatus().intValue() == 7)
        {
          event.setCloseTime(new Timestamp(System.currentTimeMillis()));
        }
        else if (event.getStatus() != before.getStatus())
        {
          EventStatusEntity statusEntity = (EventStatusEntity)this.systemService.getEntity(EventStatusEntity.class, event.getStatus());
          updateDynamics("修改事件状态为" + statusEntity.getStatusName(), eventDynamicsList);
        }
        this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
      }
      request.getSession().removeAttribute("event");
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "更新事件失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doUpdateBu"})
  @ResponseBody
  public AjaxJson doUpdateBu(EventEntity event, EventPage eventPage, HttpServletRequest request)
  {
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();
    AjaxJson j = new AjaxJson();
    String message = "更新补录成功";
    try
    {
      this.eventService.updateMain(event, eventDynamicsList, eventCommentList);
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "更新补录事件失败";
      throw new BusinessException(e.getMessage());
    }
    j.setMsg(message);
    return j;
  }

  private void sendDepart(String string, String id, String title)
  {
    HttpSession session = ContextHolderUtils.getSession();
    TSUser u = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
    String realName = u.getRealName();
    Map<String, String> extrasMap = new HashMap();

    extrasMap.put(string, id);
    ArrayList<String> imei = this.eventService.getAllImei();
    if (!imei.isEmpty())
    {
      Jpush jpush = new Jpush(imei, realName + "发布了一条无责任部门事件,请及时查看.", title, extrasMap, 1);
      try
      {
        jpush.sendPush();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }

  @RequestMapping(params={"goAdd"})
  public ModelAndView goAdd(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());
      req.setAttribute("eventPage", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-add");
  }

  @RequestMapping(params={"getTocEventType"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  @ResponseBody
  public ArrayList<EventTypeEntity> getTocEventType(HttpServletRequest request, HttpServletRequest req, String parentId)
  {
    ArrayList<EventTypeEntity> list = this.eventService.getTocEventType(parentId);
    return list;
  }

  @RequestMapping(params={"goAddBu"})
  public ModelAndView goAddBu(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());
      req.setAttribute("eventPage", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-addBu");
  }

  @RequestMapping(params={"goChangeDept"})
  public ModelAndView goChangeDept(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());
      TSDepart tSDepart = (TSDepart)this.eventService.getEntity(TSDepart.class, event.getDepart());
      req.getSession().setAttribute("event", event);
      req.getSession().setAttribute("oldDepat", tSDepart.getDepartname());
    }
    return new ModelAndView("com/gbiac/toc/event/event-modifydept");
  }

  @RequestMapping(params={"goUpdate"})
  public ModelAndView goUpdate(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);

      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-update");
  }

  private String getEventTypeParentId(String eventTypeId)
  {
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(EventTypeEntity.class);
    detachedCriteria.add(Restrictions.eq("isDelete", Integer.valueOf(0)));
    List<EventTypeEntity> eventTypeEntities = this.eventService.getEventTypeLists(detachedCriteria);
    for (EventTypeEntity eventTypeEntity : eventTypeEntities) {
      if (eventTypeEntity.getId().equals(eventTypeId))
      {
        if (StringUtils.isNotBlank(eventTypeEntity.getFatherId())) {
          return eventTypeEntity.getFatherId();
        }
        return eventTypeId;
      }
    }
    return "";
  }

  @RequestMapping(params={"goUpdateDoing"})
  public ModelAndView goUpdateDoing(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);
      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-updateDoing");
  }

  @RequestMapping(params={"goUpdateBuEdit"})
  public ModelAndView goUpdateBuEdit(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);
      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-updateBuEdit");
  }

  @RequestMapping(params={"goUpdateBu"})
  public ModelAndView goUpdateBu(EventEntity event, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(event.getId()))
    {
      event = (EventEntity)this.eventService.getEntity(EventEntity.class, event.getId());

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);
      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-updateBu");
  }

  @RequestMapping(params={"eventDynamicsList"})
  public ModelAndView eventDynamicsList(EventEntity event, HttpServletRequest req)
  {
    Object id0 = event.getId();

    String hql0 = "from EventDynamicsEntity where 1 = 1 AND eVENT_ID = ? ORDER BY createDate";
    try
    {
      List<EventDynamicsEntity> eventDynamicsEntityList = this.systemService.findHql(hql0, new Object[] { id0 });
      req.setAttribute("eventDynamicsList", eventDynamicsEntityList);
    }
    catch (Exception e)
    {
      logger.info(e.getMessage());
    }
    return new ModelAndView("com/gbiac/toc/dynamics/eventDynamicsList");
  }

  @RequestMapping(params={"eventCommentList"})
  public ModelAndView eventCommentList(EventEntity event, HttpServletRequest req)
  {
    Object id1 = event.getId();

    String hql1 = "from EventCommentEntity where 1 = 1 AND eVNET_ID = ?  ORDER BY createDate";
    try
    {
      List<EventCommentEntity> eventCommentEntityList = this.systemService.findHql(hql1, new Object[] { id1 });
      if ((eventCommentEntityList != null) && (eventCommentEntityList.size() > 0)) {
        req.setAttribute("eventCommentList", eventCommentEntityList);
      }
    }
    catch (Exception e)
    {
      logger.info(e.getMessage());
    }
    return new ModelAndView("com/gbiac/toc/comment/eventCommentList");
  }

  @RequestMapping(params={"exportXls"})
  public String exportXls(EventEntity event, Boolean isExportImage, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid, ModelMap map)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end))
      {
        Date end = new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end);
        Calendar cal = Calendar.getInstance();
        cal.setTime(end);
        cal.add(5, 1);
        String endtime = DateUtils.formatDate(cal);
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(endtime));
      }
    }
    catch (Exception e)
    {
      throw new BusinessException(e.getMessage());
    }
    cq.eq("isdelete", Integer.valueOf(0));
    cq.addOrder("createDate", SortDirection.asc);
    cq.add();
    List<EventEntity> list = this.eventService.getListByCriteriaQuery(cq, Boolean.valueOf(false));

    List<String> eventIds = new ArrayList();

    List<EventPage> pageList = new ArrayList();
    if ((list != null) && (list.size() > 0)) {
      for (EventEntity entity : list) {
        try
        {
          EventPage page = new EventPage();
          MyBeanUtils.copyBeanNotNull2Bean(entity, page);
          eventIds.add(entity.getId());
          pageList.add(page);
        }
        catch (Exception e)
        {
          logger.info(e.getMessage());
        }
      }
    }
    int i = 0;
    try
    {
      eventDynamicsLists = getEventDynamicsListByEventIds(eventIds);

      eventTypeLists = getEventTypeList();
      for (EventPage eventPage : pageList)
      {
        i++;

        List<EventDynamicsEntity> myDynamics = new ArrayList();
        EventDynamicsEntity dynamicsEntityTemp = new EventDynamicsEntity();
        StringBuffer sb = new StringBuffer(1000);
        for (EventDynamicsEntity eventDynamics : eventDynamicsLists) {
          if (eventPage.getId().equals(eventDynamics.getEventId())) {
            sb.append(eventDynamics.getDycontent()).append("\r\n");
          }
        }
        dynamicsEntityTemp.setDycontent(sb.toString());
        myDynamics.add(dynamicsEntityTemp);
        eventPage.setEventDynamicsList(myDynamics);

        String eventType = eventPage.getEventType();
        eventPage.setEventType((String)eventTypeLists.get(eventType));
        if ("0".equals(eventPage.getDepart())) {
          eventPage.setDepart("无责任部门");
        } else if (StringUtils.isBlank(eventPage.getDepart())) {
          eventPage.setDepart("");
        }
        if (StringUtils.isBlank(eventPage.getTitle())) {
          eventPage.setTitle("");
        }
        if (StringUtils.isBlank(eventPage.getRecipient())) {
          eventPage.setRecipient("");
        }
        if (!isExportImage.booleanValue())
        {
          eventPage.setBeforePic1(null);
          eventPage.setBeforePic2(null);
          eventPage.setBeforePic3(null);

          eventPage.setAfterPic1(null);
          eventPage.setAfterPic2(null);
          eventPage.setAfterPic3(null);
        }
      }
    }
    catch (Exception e)
    {
      List<EventDynamicsEntity> eventDynamicsLists;
      Map<String, String> eventTypeLists;
      e.printStackTrace();
    }
    map.put("fileName", "事件");
    map.put("entity", EventPage.class);
    map.put("params", new ExportParams("事件列表", "导出人:" + ResourceUtil.getSessionUser().getRealName(), "导出信息"));

    map.put("data", pageList);
    return "jeecgExcelView";
  }

  private List<EventDynamicsEntity> getEventDynamicsListByEventIds(List<String> eventIds)
  {
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(EventDynamicsEntity.class);
    detachedCriteria.add(Restrictions.in("eventId", eventIds.toArray()));
    detachedCriteria.addOrder(Order.asc("createDate"));
    List<EventDynamicsEntity> result = this.eventService.getEventDynamicsListByEventIds(detachedCriteria);
    return result;
  }

  private List<EventCommentEntity> getEventCotentListByEventIds(List<String> eventIds)
  {
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(EventCommentEntity.class);
    detachedCriteria.add(Restrictions.in("eventId", eventIds.toArray()));
    List<EventCommentEntity> result = this.eventService.getEventCotentListByEventIds(detachedCriteria);
    return result;
  }

  private Map<String, String> getEventTypeList()
  {
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(EventTypeEntity.class);
    detachedCriteria.add(Restrictions.eq("isDelete", Integer.valueOf(0)));

    List<EventTypeEntity> eventTypeEntities = this.eventService.getEventTypeLists(detachedCriteria);

    Map<String, String> resultMap = new HashMap();
    for (EventTypeEntity typeEntity : eventTypeEntities)
    {
      String id = typeEntity.getId();
      String fatherId = typeEntity.getFatherId();
      String name = typeEntity.getName();
      if (StringUtils.isBlank(fatherId))
      {
        resultMap.put(id, name);
      }
      else
      {
        String fatherName = (String)resultMap.get(fatherId);
        if (StringUtils.isBlank(fatherName)) {
          for (EventTypeEntity entity : eventTypeEntities) {
            if (fatherId.equals(entity.getId()))
            {
              fatherName = entity.getName();
              break;
            }
          }
        }
        if (StringUtils.isBlank(fatherName)) {
          resultMap.put(id, name);
        } else {
          resultMap.put(id, fatherName + " - " + name);
        }
      }
    }
    return resultMap;
  }

  @RequestMapping(params={"importExcel"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  @ResponseBody
  public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response)
  {
    AjaxJson j = new AjaxJson();
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    Iterator i$ = fileMap.entrySet().iterator();
    for (;;)
    {
      if (i$.hasNext())
      {
        Map.Entry<String, MultipartFile> entity = (Map.Entry)i$.next();
        MultipartFile file = (MultipartFile)entity.getValue();
        ImportParams params = new ImportParams();
        params.setTitleRows(2);
        params.setHeadRows(2);
        params.setNeedSave(true);
        try
        {
          List<EventPage> list = ExcelImportUtil.importExcel(file.getInputStream(), EventPage.class, params);
          EventEntity entity1 = null;
          for (EventPage page : list)
          {
            entity1 = new EventEntity();
            MyBeanUtils.copyBeanNotNull2Bean(page, entity1);
            this.eventService.addMain(entity1, page.getEventDynamicsList(), page.getEventCommentList());
          }
          j.setMsg("文件导入成功！");
          try
          {
            file.getInputStream().close();
          }
          catch (IOException e)
          {
            e.printStackTrace();
          }
        }
        catch (Exception e)
        {
          j.setMsg("文件导入失败！");
          logger.error(ExceptionUtil.getExceptionMessage(e));
        }
        finally
        {
          try
          {
            file.getInputStream().close();
          }
          catch (IOException e)
          {
            e.printStackTrace();
          }
        }
      }
    }
    return j;
  }

  @RequestMapping(params={"exportXlsByT"})
  public String exportXlsByT(ModelMap map)
  {
    map.put("fileName", "事件");
    map.put("entity", EventPage.class);
    map.put("params", new ExportParams("事件列表", "导出人:" + ResourceUtil.getSessionUser().getRealName(), "导出信息"));

    map.put("data", new ArrayList());
    return "jeecgExcelView";
  }

  @RequestMapping(params={"upload"})
  public ModelAndView upload(HttpServletRequest req)
  {
    req.setAttribute("controller_name", "eventController");
    return new ModelAndView("common/upload/pub_excel_upload");
  }

  @RequestMapping(params={"doAuditingyes"})
  @ResponseBody
  public AjaxJson doAuditingyes(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "审核通过成功";
    EventEntity t = (EventEntity)this.eventService.get(EventEntity.class, event.getId());
    try
    {
      this.eventService.doAuditingyesSql(t);
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "审核通过失败";
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doAuditingno"})
  @ResponseBody
  public AjaxJson doAuditingno(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "审核不通过成功";
    EventEntity t = (EventEntity)this.eventService.get(EventEntity.class, event.getId());
    try
    {
      this.eventService.doAuditingnoSql(t);
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "审核不通过失败";
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doOver"})
  @ResponseBody
  public AjaxJson doOver(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "处理完成成功";
    EventEntity t = (EventEntity)this.eventService.get(EventEntity.class, event.getId());
    try
    {
      this.eventService.doOverSql(t);
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "处理完成失败";
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doTocauditingyes"})
  @ResponseBody
  public AjaxJson doTocauditingyes(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "TOC审核通过成功";
    EventEntity t = (EventEntity)this.eventService.get(EventEntity.class, event.getId());
    try
    {
      if (t.getStatus().intValue() == 6) {
        this.eventService.doTocauditingyesSql(t);
      } else {
        message = "事件无法审核,请单选且状态为TOC审核中的事件";
      }
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "TOC审核通过失败";
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(params={"doTocauditingno"})
  @ResponseBody
  public AjaxJson doTocauditingno(EventEntity event, HttpServletRequest request)
  {
    AjaxJson j = new AjaxJson();
    String message = "TOC审核不通过成功";
    EventEntity t = (EventEntity)this.eventService.get(EventEntity.class, event.getId());
    try
    {
      if (t.getStatus().intValue() == 6) {
        this.eventService.doTocauditingnoSql(t);
      } else {
        message = "无法审核,请单选且状态为TOC审核中的事件";
      }
      this.systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    catch (Exception e)
    {
      e.printStackTrace();
      message = "TOC审核不通过失败";
    }
    j.setMsg(message);
    return j;
  }

  @RequestMapping(method={org.springframework.web.bind.annotation.RequestMethod.GET})
  @ResponseBody
  public List<EventEntity> list()
  {
    List<EventEntity> listEvents = this.eventService.getList(EventEntity.class);
    return listEvents;
  }

  @RequestMapping(value={"/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
  @ResponseBody
  public ResponseEntity<?> get(@PathVariable("id") String id)
  {
    EventEntity task = (EventEntity)this.eventService.get(EventEntity.class, id);
    if (task == null) {
      return new ResponseEntity(HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity(task, HttpStatus.OK);
  }

  @RequestMapping(method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"application/json"})
  @ResponseBody
  public ResponseEntity<?> create(@RequestBody EventPage eventPage, UriComponentsBuilder uriBuilder)
  {
    Set<ConstraintViolation<EventPage>> failures = this.validator.validate(eventPage, new Class[0]);
    if (!failures.isEmpty()) {
      return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
    }
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();

    EventEntity event = new EventEntity();
    try
    {
      MyBeanUtils.copyBeanNotNull2Bean(event, eventPage);
    }
    catch (Exception e)
    {
      logger.info(e.getMessage());
    }
    this.eventService.addMain(event, eventDynamicsList, eventCommentList);

    String id = eventPage.getId();
    URI uri = uriBuilder.path("/rest/eventController/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }

  @RequestMapping(value={"/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.PUT}, consumes={"application/json"})
  public ResponseEntity<?> update(@RequestBody EventPage eventPage)
  {
    Set<ConstraintViolation<EventPage>> failures = this.validator.validate(eventPage, new Class[0]);
    if (!failures.isEmpty()) {
      return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
    }
    List<EventDynamicsEntity> eventDynamicsList = eventPage.getEventDynamicsList();
    List<EventCommentEntity> eventCommentList = eventPage.getEventCommentList();

    EventEntity event = new EventEntity();
    try
    {
      MyBeanUtils.copyBeanNotNull2Bean(event, eventPage);
    }
    catch (Exception e)
    {
      logger.info(e.getMessage());
    }
    this.eventService.updateMain(event, eventDynamicsList, eventCommentList);

    return new ResponseEntity(HttpStatus.NO_CONTENT);
  }

  @RequestMapping(value={"/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.DELETE})
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void delete(@PathVariable("id") String id)
  {
    EventEntity event = (EventEntity)this.eventService.get(EventEntity.class, id);
    this.eventService.delMain(event);
  }

  @RequestMapping(params={"getFiles"})
  @ResponseBody
  public AjaxJson getFiles(String id)
  {
    List<CgUploadEntity> uploadBeans = this.cgFormFieldService.findByProperty(CgUploadEntity.class, "cgformId", id);
    List<Map<String, Object>> files = new ArrayList(0);
    for (CgUploadEntity b : uploadBeans)
    {
      String title = b.getAttachmenttitle();
      String fileKey = b.getId();
      String path = b.getRealpath();
      String field = b.getCgformField();
      Map<String, Object> file = new HashMap();
      file.put("title", title);
      file.put("fileKey", fileKey);
      file.put("path", path);
      file.put("field", field == null ? "" : field);
      files.add(file);
    }
    AjaxJson j = new AjaxJson();
    j.setObj(files);
    return j;
  }

  @RequestMapping(params={"assign"})
  public ModelAndView assign(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListAssign");
  }

  @RequestMapping(params={"send"})
  public ModelAndView send(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListSend");
  }

  @RequestMapping(params={"closed"})
  public ModelAndView closed(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListClosed");
  }

  @RequestMapping(params={"timeOuting"})
  public ModelAndView timeOuting(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListTimeouting");
  }

  @RequestMapping(params={"timeOuted"})
  public ModelAndView timeOuted(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListTimeouted");
  }

  @RequestMapping(params={"mx"})
  public ModelAndView mx(HttpServletRequest request)
  {
    return new ModelAndView("com/gbiac/toc/event/eventListMx");
  }

  public void updateDynamics(String message, List<EventDynamicsEntity> list)
  {
    EventDynamicsEntity entity = new EventDynamicsEntity();
    entity.setCreateDate(new Date());
    TSUser user = ResourceUtil.getSessionUser();
    String name = user.getRealName();
    String date = DateUtils.getDate("MM-dd HH:mm");
    entity.setDycontent(date + name + message);
    list.add(entity);
  }

  public void sendInfo(String extras, String id, String title, String departId)
  {
    HttpSession session = ContextHolderUtils.getSession();
    TSUser u = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
    String realName = u.getRealName();
    Map<String, String> extrasMap = new HashMap();

    extrasMap.put(extras, id);
    ArrayList<String> imei = this.eventService.getImei(departId);
    if (imei.size() > 0)
    {
      Jpush jpush = new Jpush(imei, realName + "刚刚给您派发了新事件，请您及时下派.", title, extrasMap, 1);
      try
      {
        jpush.sendPush();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }

  public void sendRecipient(String pid, String eventId, String title, String content)
  {
    Map<String, String> extrasMap = new HashMap();

    extrasMap.put("2", eventId);
    ArrayList<String> list = new ArrayList();
    String imei = this.eventService.sendRecipient(pid);
    if (StringUtils.isNotBlank(imei))
    {
      list.add(imei);
      Jpush jpush = new Jpush(list, title, content, extrasMap, 1);
      try
      {
        jpush.sendPush();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }

  public void sendRecipientadd(String pid, String eventId, String title, String content)
  {
    Map<String, String> extrasMap = new HashMap();

    extrasMap.put("10", eventId);
    ArrayList<String> list = new ArrayList();
    String imei = this.eventService.sendRecipient(pid);
    if (StringUtils.isNotBlank(imei))
    {
      list.add(imei);
      Jpush jpush = new Jpush(list, title, content, extrasMap, 1);
      try
      {
        jpush.sendPush();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
  }

  @RequestMapping(params={"getPerson"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  @ResponseBody
  public AjaxApiJson getPerson(HttpServletRequest request, @RequestParam("pid") String depart)
  {
    AjaxApiJson json = new AjaxApiJson();
    if (StringUtils.isNotBlank(depart))
    {
      ArrayList<Person> list = this.eventService.getPerson(depart);
      json.setData(list);
      json.setMsg("查询成功");
    }
    else
    {
      json.setSuccess(false);
    }
    return json;
  }

  @RequestMapping(params={"getDepart"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  @ResponseBody
  public AjaxApiJson getDepart(HttpServletRequest request)
  {
    AjaxApiJson json = new AjaxApiJson();
    ArrayList<MyDepart> list = this.eventService.getDepart();
    json.setData(list);
    json.setMsg("查询成功");
    return json;
  }

  @RequestMapping(params={"getRealName"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  @ResponseBody
  public AjaxApiJson getRealName(HttpServletRequest request, String pid)
  {
    AjaxApiJson json = new AjaxApiJson();
    String name = this.eventService.getRealName(pid);
    json.setData(name);
    json.setMsg("查询成功");
    return json;
  }

  @RequestMapping(params={"datagridzp"})
  public void datagridzp(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();
    String createName = event.getCreateName();
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end)) {
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_end));
      }
      cq.eq("status", Integer.valueOf(2));
      cq.eq("isdelete", Integer.valueOf(0));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();

    this.eventService.getDataGridReturn(cq, true);

    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"datagridsh"})
  public void datagridsh(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();
    String createName = event.getCreateName();
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end)) {
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(query_createDate_end));
      }
      cq.eq("status", Integer.valueOf(6));
      cq.eq("isdelete", Integer.valueOf(0));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();

    this.eventService.getDataGridReturn(cq, true);

    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"getMessage"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  public void getMessage(HttpServletRequest request, HttpServletResponse response)
          throws IOException
  {
    StringBuffer json = new StringBuffer("{");
    String msgNum = this.eventService.getNodo();
    json.append("'msg':'" + msgNum + "'");
    json.append("}");
    try
    {
      PrintWriter out = response.getWriter();
      out.write(json.toString());
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }

  @RequestMapping(params={"datagridycs"})
  public void datagridycs(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();

    String createName = event.getCreateName();
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end))
      {
        Date end = new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end);
        Calendar cal = Calendar.getInstance();
        cal.setTime(end);
        cal.add(5, 1);
        String endtime = DateUtils.formatDate(cal);
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(endtime));
      }
      cq.eq("timeoutStatus", Integer.valueOf(3));
      cq.eq("isdelete", Integer.valueOf(0));

      cq.notEq("status", Integer.valueOf(7));
      cq.notEq("status", Integer.valueOf(9));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();

    this.eventService.getDataGridReturn(cq, true);

    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"goUpdatezp"})
  public ModelAndView goUpdateKuai(String id, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(id))
    {
      EventEntity event = (EventEntity)this.eventService.getEntity(EventEntity.class, id);

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);
      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-updatezp");
  }

  @RequestMapping(params={"datagridjjcs"})
  public void datagridjjcs(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();

    String createName = event.getCreateName();
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end))
      {
        Date end = new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end);
        Calendar cal = Calendar.getInstance();
        cal.setTime(end);
        cal.add(5, 1);
        String endtime = DateUtils.formatDate(cal);
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(endtime));
      }
      cq.eq("timeoutStatus", Integer.valueOf(2));
      cq.eq("isdelete", Integer.valueOf(0));

      cq.notEq("status", Integer.valueOf(7));
      cq.notEq("status", Integer.valueOf(9));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();

    this.eventService.getDataGridReturn(cq, true);

    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"goUpdatebianji"})
  public ModelAndView goUpdatebianji(String id, HttpServletRequest req)
  {
    if (StringUtil.isNotEmpty(id))
    {
      EventEntity event = (EventEntity)this.eventService.getEntity(EventEntity.class, id);

      String parentId = getEventTypeParentId(event.getEventType());
      req.setAttribute("eventParent", parentId);

      req.setAttribute("eventPage", event);
      String recipient = event.getRecipient();
      if ((recipient != null) && (!recipient.equals("")))
      {
        String name = this.eventService.getName(recipient);
        req.setAttribute("recipent", name);
      }
      HttpSession session = req.getSession();
      session.setAttribute("event", event);
    }
    return new ModelAndView("com/gbiac/toc/event/event-updatebianji");
  }

  @RequestMapping(params={"getZpTotal"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  public void getZpTotal(HttpServletRequest request, HttpServletResponse response)
          throws IOException
  {
    StringBuffer json = new StringBuffer("{");
    HttpSession session = request.getSession();
    String before = (String)session.getAttribute("beforeZp");
    String msgNum = this.eventService.getZpTotal(before);
    if (StringUtils.isNotBlank(before))
    {
      if (before.equals(msgNum))
      {
        json.append("'msg':'1'");
        json.append("}");
      }
      else
      {
        json.append("'msg':'0'");
        json.append("}");
      }
    }
    else
    {
      json.append("'msg':'1'");
      json.append("}");
    }
    session.setAttribute("beforeZp", msgNum);
    try
    {
      PrintWriter out = response.getWriter();
      out.write(json.toString());
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }

  @RequestMapping(params={"getShTotal"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  public void getShTotal(HttpServletRequest request, HttpServletResponse response)
          throws IOException
  {
    StringBuffer json = new StringBuffer("{");
    HttpSession session = request.getSession();
    String before = (String)session.getAttribute("beforeSh");
    String msgNum = this.eventService.getShTotal(before);
    if (StringUtils.isNotBlank(before))
    {
      if (before.equals(msgNum))
      {
        json.append("'msg':'1'");
        json.append("}");
      }
      else
      {
        json.append("'msg':'0'");
        json.append("}");
      }
    }
    else
    {
      json.append("'msg':'1'");
      json.append("}");
    }
    session.setAttribute("beforeSh", msgNum);
    try
    {
      PrintWriter out = response.getWriter();
      out.write(json.toString());
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }

  @RequestMapping(params={"datagridBu"})
  public void datagridBu(EventEntity event, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid)
  {
    CriteriaQuery cq = new CriteriaQuery(EventEntity.class, dataGrid);
    String title = event.getTitle();
    String number = event.getNumber();
    String content = event.getContent();
    String source = event.getSource();
    String recipient = event.getRecipient();
    String createName = event.getCreateName();
    if (StringUtils.isNotBlank(createName))
    {
      event.setCreateName(null);
      cq.like("createName", "%" + createName + "%");
    }
    if (StringUtils.isNotBlank(recipient))
    {
      ArrayList<String> ids = this.eventService.seachName(recipient);
      event.setRecipient(null);
      cq.add(Restrictions.in("recipient", ids));
    }
    if (StringUtils.isNotBlank(content)) {
      event.setContent("*" + content + "*");
    }
    if (StringUtils.isNotBlank(source)) {
      event.setSource("*" + source + "*");
    }
    if (StringUtils.isNotBlank(title)) {
      event.setTitle("*" + title + "*");
    }
    if (StringUtils.isNotBlank(number)) {
      event.setNumber("*" + number + "*");
    }
    HqlGenerateUtil.installHql(cq, event);
    try
    {
      String query_createDate_begin = request.getParameter("createDate_begin");
      String query_createDate_end = request.getParameter("createDate_end");
      if (StringUtil.isNotEmpty(query_createDate_begin)) {
        cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
      }
      if (StringUtil.isNotEmpty(query_createDate_end))
      {
        Date end = new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end);
        Calendar cal = Calendar.getInstance();
        cal.setTime(end);
        cal.add(5, 1);
        String endtime = DateUtils.formatDate(cal);
        cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(endtime));
      }
      cq.eq("checkStatus", Integer.valueOf(3));
      cq.eq("isdelete", Integer.valueOf(0));

      dataGrid.setSort("createDate");
      dataGrid.setOrder("desc");
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new BusinessException(e.getMessage());
    }
    cq.add();
    this.eventService.getDataGridReturn(cq, true);
    TagUtil.datagrid(response, dataGrid);
  }

  @RequestMapping(params={"checkNumber"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  public void checkNumber(HttpServletRequest request, HttpServletResponse response, String number)
          throws IOException
  {
    HttpSession session = request.getSession();
    EventEntity attribute = (EventEntity)session.getAttribute("event");
    if ((StringUtils.isNotBlank(attribute.getNumber())) &&
            (attribute.getNumber().equals(number))) {
      return;
    }
    String msgNum = this.eventService.isNumber(number);
    JSONObject jsonStr = new JSONObject();
    jsonStr.put("msg", msgNum);
    try
    {
      PrintWriter out = response.getWriter();
      out.write(jsonStr.toString());
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }

  @RequestMapping(params={"updateLive"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
  public void updateLive(String parm)
  {
    this.eventService.updateLive(parm);
  }

  @RequestMapping(params={"checkNumberadd"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
  public void checkNumberadd(HttpServletRequest request, HttpServletResponse response, String number)
          throws IOException
  {
    String msgNum = this.eventService.isNumberadd(number);
    HttpSession session = request.getSession();
    JSONObject jsonStr = new JSONObject();
    jsonStr.put("msg", msgNum);
    try
    {
      PrintWriter out = response.getWriter();
      out.write(jsonStr.toString());
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
}
